// pages/rankRadio/rankRadio.js

import request from '../../utils/request'
Page({

  /**
   * 页面的初始数据
   */
  data: {
    navState: 0,//导航状态
    rankList: [],//节目排行数组
    meiriList: [],//每日
    zhuboList: [],//主播
    rankListT: [],
  },

  //监听滑块
  bindchange(e) {
    // console.log(e.detail.current)
    let index = e.detail.current;
    this.setData({
      navState: index
    })
  },
  //点击导航
  navSwitch: function (e) {
    // console.log(e.currentTarget.dataset.index)
    let index = e.currentTarget.dataset.index;
    this.setData({
      navState: index
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.getRankList()
    this.getMeiriList()
    this.getZhuboList()
  },


  async getRankList(){
    let rankListData = await request('/dj/program/toplist',{limit: 52})
    console.log(rankListData)
    this.setData({
      rankListT: rankListData,
      rankList: rankListData.toplist
    })
    console.log(this.data.rankList)
  },
  async getMeiriList(){
    let meiriListData = await request('/dj/program/toplist/hours',{limit: 52})
    console.log(meiriListData)
    this.setData({
      meiriList: meiriListData.data.list
    })
    console.log(this.data.meiriList)
  },
  async getZhuboList(){
    let zhuboListData = await request('/dj/toplist/popular',{limit: 52})
    console.log(zhuboListData)
    this.setData({
      zhuboList: zhuboListData.data.list
    })
    console.log(this.data.zhuboList)
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})